<?php

namespace Admin\Controller;
use Think\Controller;
use Common\Controller\AuthController;
use Think\Auth;

class TixianController extends AuthController{
	
	
	/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/


	public function setFee(){

    if (!IS_AJAX)
        {
            $sys=M('sys')->where(array('sys_id'=>1))->find();
            $this->assign('sys',$sys)->display();
      }
        else
        {
         $_POST['tixian_fee_open']=$_POST['tixian_fee_open']?$_POST['tixian_fee_open']:0;
        M('sys')->save($_POST);
        $this->success('设置保存成功',1,1);
      }
	}
	

  public function audit(){
     $limits=C('PAGE_SIZE');
     //$limits=2;
   $lists= M('tixian')->page(I('get.p'),$limits)->select();
   $tixian_fee=M('sys')->getField('tixian_fee');
   foreach ($lists as $key => $value) {
       $user_info= M('user')->where(array('id' => $value['user_id']))->find();
      $lists[$key]['truename']=$user_info['truename'];
      $lists[$key]['mobile']=$user_info['mobile'];
      $lists[$key]['idcard']=$user_info['idcard'];
        }
     $count = M('tixian')->count(); 
         $p = getpage($count,$limits);
         //$p = getpage($count,C('PAGE_SIZE'));
         $show = $p->show();    
    $this->assign('lists',$lists);
    $this->assign('page',$show);
    $this->assign('tixian_fee',$tixian_fee);
   $this->display();
  }



  public function editTixian($id=0)
  {
    if ($id = (int)$id) {
            $obj = M('tixian');
            if (!$detail = $obj -> find($id)) {
                $this -> error('请选择要提现的条目');
            }
                $data['status']=1;
                $data['id'] = $id;
                $data['audit_time'] = time();
                if ($obj -> save($data)) {
                    $this -> success('操作成功', U('Tixian/audit'));
                } else {
                    $this -> error('操作失败');
                }
            
        } else {
            $this -> error('请选择要提现的条目2');
        }
  }



  public function delTixian($id='')
  {
    if ($id = (int)$id) {
            $obj = M('tixian');
            if (!$detail = $obj -> find($id)) {
                $this -> error('请选择要提现的条目');
            }
                if ($obj -> delete($id)) {
                    $this -> success('操作成功', U('Tixian/audit'));
                } else {
                    $this -> error('操作失败');
                }
            
        } else {
            $this -> error('请选择要提现的条目2');
        }
  }
}
